/**
 * Copyright (c) 2016-2019 人人开源 All rights reserved.
 *
 * https://www.renren.io
 *
 * 版权所有，侵权必究！
 */

package com.keshe.member.service.impl;

import com.keshe.member.dao.UserDao;
import com.keshe.member.dao.UserTokenDao;
import com.keshe.member.entity.UserEntity;
import com.keshe.member.entity.UserTokenEntity;
import com.keshe.member.service.ShiroService;
import io.renren.common.utils.Constant;
import io.swagger.models.auth.In;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

@Service
public class ShiroServiceImpl implements ShiroService {
    @Autowired
    private UserDao userDao;
    @Autowired
    private UserTokenDao userTokenDao;

    @Override
    public Set<String> getUserPermissions(int userId) {
        List<String> permsList;

        //用户权限列表
        Set<String> permsSet = new HashSet<>();
//        for(String perms : permsList){
//            if(StringUtils.isBlank(perms)){
//                continue;
//            }
//            permsSet.addAll(Arrays.asList(perms.trim().split(",")));
//        }
        return permsSet;
    }

    @Override
    public UserTokenEntity queryByToken(String token) {
        return userTokenDao.queryByToken(token);
    }

    @Override
    public UserEntity queryUser(Integer userId) {
        return userDao.selectById(userId);
    }
}
